﻿using System;
using System.Collections.Generic;

using System.Text;
using Microsoft.VisualStudio.DebuggerVisualizers;
using System.Management.Automation.Runspaces;
using System.Windows.Forms;
using System.Data;
using PoSHEditor;

[assembly: System.Diagnostics.DebuggerVisualizer(
   typeof(PoSHVisualizer.PoSHVisualizer),
   Target = typeof(DataSet),
   Description = "PowerShell Debugger Viewer")]
namespace PoSHVisualizer
{
    public class PoSHVisualizer : DialogDebuggerVisualizer
    {
        protected override void Show(
            IDialogVisualizerService windowService,
            IVisualizerObjectProvider objectProvider)
        {
            try
            {
                frmPoSHVisualizer frm = new frmPoSHVisualizer(objectProvider.GetObject());
                windowService.ShowDialog(frm);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "PowerShell Debugger Viewer", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        public void SetVariable(string name, object value)
        {
            Singletons.TheScriptEngine.SetVariable(name, value);
        }
    }
}